package com.heima.kafka.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jack
 * @data 2024 10:08
 */
@RestController
@RequestMapping("/api/v1/kafka")
public class HelloController {

    @Autowired
    private KafkaTemplate<String,String> kafkaTemplate;

    @GetMapping("/send")
    public String sendMsg(){
        kafkaTemplate.send("hello-topic",0,"abc","hello,kafka");
        return "success";
    }
}
